import dictDataLoader from "./dictDataLoader";
import session from './session';
import nt from "./network";

var md = {
    auth: null,
    objList: null,
    data() {
        //console.log(this.objList);
        if (this.objList == null) {
            this.objList = [];
            var th = this;
            dictDataLoader.getData('obj', th, 'objList', (data) => {
                this.objList = data.content;
                console.log('对象权限: ');
                console.log(this.objList);
            });

        }
        return this.objList;
    },
    /**
     *初始化
     */
    initDictData() {
        var th = this;
        dictDataLoader.getData('obj', th, 'objList', (data) => {});
    },
    authObjSearch(objType, objName) {
        return false;
    },
    authObj(objType, objName) {

        //return false;

        this.dataList = session.getObjRoleList();
        for (var idx in this.dataList) {
            var item = this.dataList[idx];
            //if (item.roleId != session.getRoleId()) {
            //    continue;
            //}
            if (item.objType != objType) {
                continue;
            }
            if (item.objName == objName) {
                return false;
            }
        }
        return true;
        // if (this.auth == null) {
        //     let queryObject = {
        //         objType: objType,
        //         objName: objName
        //     };
        //     nt.doRequest({
        //         method: "post",
        //         uri: "/ivorytower/platformmgr/v1/sysObj/auth",
        //         data: queryObject,
        //         onSuccess: resp => {
        //             this.auth = !resp.data.content;
        //         }
        //     });

        //     return this.auth;
        // }


    }
}


export default md;